﻿using System;
using System.Web.UI.WebControls;
using Model;
using Service;



public partial class LoginView : System.Web.UI.Page
{

    readonly ReferenceDataService _ReferenceDataService = new ReferenceDataService();
    private readonly DirectServiceLogin _DriveServiceLogin = new DirectServiceLogin();
    protected void Page_Load(object sender, EventArgs e)
    {
        FirstLoading();
    }
    private void FirstLoading()
    {
        m_login.UserName = " ";    
    }
    protected void m_login_Authenticate(object sender, AuthenticateEventArgs e)
    {
        try
        {
           
            Employee  employee = _ReferenceDataService.IsEmployeeExist(m_login.UserName.Trim(), m_login.Password);
           
                if (employee.EmployeeId != 0)
                {
                    Session["userFullDomain"] = employee.FullDomain;
                    Session["GroupId"] = employee.GroupId;
                    Response.Redirect("Default.aspx");
                    return;
                }
        }
        catch (Exception ex)
        {
            this.Validators.Add(new ValidatorMessage(ex.ToString()));
        }
    }
}
